const express = require("express");
const app = express();
const port = 9527;
const student = require("./model/student");
// console.log(student)
app.use(express.json()); // for parsing application/json
// 获取一个学生
app.get("/getStudent", (req, res) => {
  student
    .findOne({
      where: { id: 1 },
    })
    .then((result) => {
      res.send({ code: 200, data: result, msg: "查询成功" });
    });
});
// 新增一个学生
app.post("/addStudent", (req, res) => {
  console.log(req.body);
  const result = student.create({ ...req.body });
  res.send({ code: 200, data: result, msg: "新增成功" });
});
// 删除
app.get("/deleteStudent", (req, res) => {
  res.send("Hello World!");
});
// 分页查询学生
app.get("/getStudentList", (req, res) => {
  res.send("Hello World!");
});
app.listen(port, () => {
  console.log(`Example app listening on port ${port}`);
});
